#include <iostream>
#include <map>
#include <vector>
#include <sstream>
#include <algorithm>
#include <fstream>

using namespace std;

typedef pair<string,int > siPair;

struct Dump
{
    Dump(int i):n(i){}
    void operator()(siPair e)
    {
        if( e.second >= n )
           cout << e.first << "  " << e.second << endl;
    }
    int n;
};


struct Comp
{
    bool operator()(siPair e1, siPair e2)
    {

        return e1.second > e2.second;
    }
};

int main()
{
    map<string, int> vote;
    ifstream in("in.txt");

    string name;
    while( in >> name  )
    {
          ++vote[name];

    }

    vector<siPair> vec( vote.begin(), vote.end()   );
    sort(vec.begin(), vec.end(),Comp() );
    for_each(vec.begin(), vec.end(), Dump(2) );












    cout << "Hello world!" << endl;
    return 0;
}
